package com.alisoft.nano.seda.test;

import java.util.Map;
import java.util.concurrent.CountDownLatch;

import junit.framework.Assert;

import com.alisoft.nano.seda.Event;
import com.alisoft.nano.seda.notification.EventMachineNotificationListener;

@SuppressWarnings("serial")
public class SimpleEventCompletedNotificationListener extends
		EventMachineNotificationListener<Map<String, String>> {

	private CountDownLatch latch;

	@Override
	protected void onCompleted(Event<Map<String, String>> event) {
		System.out.println("Event completed --- "
				+ event.getWorkUnit().get("index") + ","
				+ event.getWorkUnit().get("result"));
		latch.countDown();
		Assert.assertEquals("processed", event.getWorkUnit().get("result"));
	}

	public void setLatch(CountDownLatch latch) {
		this.latch = latch;
	}

}
